<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
	$_data["ID"] = addslashes($_data["ID"]);
	$strSQL = "select * from `bet_Gamble` where ID = ".$_data["ID"];

	if($RS = @PMA_mysql_query($strSQL, $$_Conn)){
		if(PMA_mysql_num_rows($RS) == 0){
			@mysql_free_result($RS);
			header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List");
			exit();
		}else{
			$Rows = PMA_mysql_fetch_object($RS);
		}
		@mysql_free_result($RS);
	}else{
		header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List");
		exit();
	}

	$GD = DateForm($Rows -> GameDate, $Rows -> GameTime);
	$GT = TimeForm($Rows -> GameDate, $Rows -> GameTime);
	$strLotto = GetRelationType2 ("`bet_Lotto`", $Rows -> LottoID, " ID, Lotto_".$_intLang." as Value ");
	
	if($Rows -> isEnd == 1){
		$strScore = GetRelationType3 ("`bet_GambleScore`", " GambleID = ".$_data["ID"], " ID, CONCAT(NumberNormal, '#', NumberSpecial) as Value ");
		$arrNumber = split("#", $strScore);
	}

	$strSQL = "select Bet_Type, Number, Count(*) as total, ROUND(sum(MemStake*MemExchangeRate*StockRate)) as betstatus, ROUND(sum(StockRateResult)) as stockrateresult from `bet_BetList` where GambleID = ".$_data["ID"]." group by Bet_Type, Number";

	$RS = @PMA_mysql_query($strSQL, $$_Conn);
	while($Rows = PMA_mysql_fetch_object($RS)){
		$arrT["total"] = $Rows -> total;
		$arrT["betstatus"] = $Rows -> betstatus;
		$arrT["stockrateresult"] = $Rows -> stockrateresult;
		$arrA[$Rows -> Bet_Type][$Rows -> Number] = $arrT;
	}
?>
<html>
<head>
<title> <?php print $_strCompetition["Account_Title"];?></title>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<link rel="stylesheet" href="/css/backend.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form method="Get" Action="index.php" name="ListForm">
	<input type="hidden" name="op" value="CountResult">
	<input type="hidden" name="ID" value="<?php print $_data["ID"];?>">
	<input type="hidden" name="LottoID" value="<?php print $Rows -> LottoID;?>">
  <table width="750" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td> 
        <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999" class="content_b">
          <tr> 
            <td colspan="6" class="MyUp"><?php print $_strCompetition["Account_Title"];?></td>
          </tr>
          <tr> 
            <td class="MyTitleL" align="center"><?php print $_strCompetition["List_Time"];//時間?></td>
            <td class="MyTitleL" align="center"><?php print $_strCompetition["List_GameNo"];//場次?></td>
            <td class="MyTitleL" align="center"><?php print $_strCompetition["List_Team"];//樂透?></td>
			<td class="MyTitleL" align="center"><?php print $_strCompetition["NumberNormal"];?><!--正碼//--></td>
			<td class="MyTitleL" align="center"><?php print $_strCompetition["NumberSpecial"];?><!--特別碼//--></td>
          </tr>
          <tr> 
            <td class="MyCellL" align="center"><?php print $GD;?><br><?php print $GT;?></td>
			<td class="MyCellL" align="center"><?php print $Rows -> SerialNo;?></td>
            <td class="MyCellL" align="center"><?php print $strLotto;?></td>
			<td class="MyCellL" align="center"><?php print $arrNumber[0];?></td>
			<td class="MyCellL" align="center"><?php print $arrNumber[1];?></td>
          </tr>
<?php for($i = 1; $i < sizeof($_arrBet_Type); $i++){ ?>
          <tr> 
            <td class="MyCellL" align="center"><?php print $_arrBet_Type[$i];?></td>
            <td class="MyCellL" align="left" colspan="4">
	<?php
	if(is_array($arrA[$i])){
		print "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
		switch($i){
			case 1:
			case 4:
				for($k = 1; $k <= 10; $k++){
					print "<tr>";
					for($m = 0; $m < 5; $m++){
						$intNum = $k + $m*10;
						print "<td width=\"120\"><b class=\"wager_color_blue\">".$intNum."</b><br /><a class=\"wager_color_red\">".$arrA[$i][$intNum]["total"]." / ".$arrA[$i][$intNum]["betstatus"]." / ".$arrA[$i][$intNum]["stockrateresult"]."</a></td>";
					}
					print "</tr>";
				}
				break;

			case 2:
			case 3:
			case 5:
			case 6:
				print "<tr>";
				print "<td width=\"120\"><b class=\"wager_color_blue\">0</b><br /><a class=\"wager_color_red\">".$arrA[$i][0]["total"]." / ".$arrA[$i][0]["betstatus"]." / ".$arrA[$i][0]["stockrateresult"]."</a></td>";
				print "<td width=\"120\"><b class=\"wager_color_blue\">1</b><br /><a class=\"wager_color_red\">".$arrA[$i][1]["total"]." / ".$arrA[$i][1]["betstatus"]." / ".$arrA[$i][1]["stockrateresult"]."</a></td>";
				print "</tr>";
				break;
		}
		print "</table>";
	}
	?>
			</td>
          </tr>
<?php } ?>
        </table>        
      </td>
    </tr>
  </table>
  <a style="color: #FF0000; font-size: 12px">*<?php print $_strCompetition["TimeZone"];?></a>
</form>

</body>
</html>